package org.yinxianren.www.study_02.study.java8;

import org.junit.Test;
import org.yinxianren.www.study_02.study.utils.PayMap;

import java.util.Arrays;

public class Study03 {

    @Test
    public void study_01(){

        PayMap<String,Object> map= new PayMap<>();
        map.lput("red",589).lput("green",800);
        map.forEach((k,v)->{
            System.out.println(k+":"+v);
        });

    }

    @Test
    public void study_02(){
        PayMap<String,Object> map=new PayMap<>();
        map.lput("age",18)
                .lput("name","xiaobai")
                .lput("addr","xiamen");

        System.out.println(map.toString());
        PayMap<String,Object> map2=new PayMap<>();
        String mapStr=map.toString();
        mapStr=mapStr.substring(1,mapStr.length()-1);
        //name=xiaobai, addr=xiamen, age=18
        Arrays.stream(mapStr.split(","))
                .map(str->str.split("="))
                .map(arry->map2.put(arry[0],arry[1]))
                .count();

        System.out.println(map2.toString());

    }



}
